package com.itboye.pondteam.custom;

import android.app.AlertDialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.itboye.pondteam.R;

/**
 * Created by Mr.w on 2017/5/13.
 */

public class XAlertDialog extends AlertDialog implements View.OnClickListener {
    private EditText edit_content;  //编辑框
    private TextView btn_ok, btn_cancel;  //确定取消按钮
    private OnEditInputFinishedListener mListener; //接口
    public XAlertDialog(Context context, OnEditInputFinishedListener mListener) {
        super(context);
        this.mListener = mListener;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_ok:
                this.mListener.editInputFinished(edit_content.getText().toString());
                break;
            case R.id.btn_cancel:
                dismiss();
                break;
        }
    }

    public interface OnEditInputFinishedListener{
        void editInputFinished(String password);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.alert_x);
        //控件
        edit_content = (EditText)findViewById(R.id.edit_content);
        btn_ok = (TextView)findViewById(R.id.btn_ok);
        btn_cancel = (TextView)findViewById(R.id.btn_cancel);

        btn_ok.setOnClickListener(this);
        btn_cancel.setOnClickListener(this);
    }
}
